import {Service} from "./Server";

/**
 * 添加到收藏
 * @param username 用户名
 * @param articleId 文章id
 */
export function addLike(username, articleId) {
  return Service({
    url: `/blogs-like/addLike`,
    params: {
      username,
      articleId,
    }
  })
}

/**
 * 是否已经收藏这个文章
 * @param username 用户名
 * @param articleId 文章id
 */
export function isHaveLike(username, articleId) {
  return Service({
    url: `/blogs-like/isHaveLike`,
    params: {
      username,
      articleId,
    }
  })
}

/**
 * 获取这个文章的作者信息
 * @param author 作者名
 */
export function getAuthorInfo(author) {
  return Service({
    url: `/blog-author/getAuthorInfo`,
    params: {
      author: author
    }
  })
}


/**
 * 获取作者的文章的数量
 * @param author 作者名
 */
export function getAuthorArticleCount(author) {
  return Service({
    url: `/blog-author/getAuthorArticleCount`,
    params: {
      author: author
    }
  })
}

/**
 * 获取作者的所有的文章点赞数
 * @param author 作者名
 */
export function getPraise(author) {
  return Service({
    url: `/blog-author/getPraise`,
    params: {
      author: author
    }
  })
}

/**
 * 查询当前用户是否已经关注此
 * @param authorId 作者id
 * @param userId 用户id
 */
export function isFocus(authorId, userId) {
  return Service({
    url: `/user-author/isFoursOn`,
    params: {
      authorId: authorId,
      userId: userId
    }
  })
}

/**
 * 添加到关注
 * @param authorId 作者id
 * @param userId 用户id
 */
export function addFocus(authorId, userId) {
  return Service({
    url: `/user-author/addFocus`,
    params: {
      authorId: authorId,
      userId: userId
    }
  })
}

/**
 * 取消关注
 * @param authorId 作者id
 * @param userId 用户id
 */
export function cancelFocus(authorId, userId) {
  return Service({
    url: `/user-author/cancelFocus`,
    params: {
      authorId: authorId,
      userId: userId
    }
  })
}

/**
 * 根据标签获取相关
 * @param userId 标签名字
 */
export function getRelated(tagName) {
  return Service({
    url: `/tags/getRelated`,
    params: {
      articleTags: tagName,
    }
  })
}

export function addRecords(username, articleId) {
  return Service({
    url: `/records/addRecords`,
    params: {
      username: username,
      articleId: articleId
    }
  })
}

/**
 * 获取最新发布的文章
 * @param pageSize 每页多少条
 * @param page 多少页
 */
export function getLaster(page, pageSize) {
  return Service({
    url: `/recommend/getLaster`,
    params: {
      page: page,
      pageSize: pageSize,
    }
  })
}


/**
 * 获取最新发布的文章
 * @param pageSize 每页多少条
 * @param page 多少页
 * @param hotType 查询热点类型
 */
export function getHot(page, pageSize, hotType) {
  return Service({
    url: `/getHot/getHotList`,
    params: {
      page: page,
      pageSize: pageSize,
      hotType: hotType,
    }
  })
}

/**
 * 点赞文章和再次点击取消点赞
 * @param username
 * @param articleId
 * @returns {AxiosPromise}
 */
export function addPraise(username,articleId) {
  return Service({
    url: `/blogs-praise/addPraise`,
    params: {
      username:username,
      articleId:articleId
    }
  })
}

/**
 * 判断是否已点赞
 * @param username
 * @param articleId
 * @returns {AxiosPromise}
 */
export function ifPraise(username,articleId) {
  return Service({
    url: `/blogs-praise/ifPraise`,
    params: {
      username:username,
      articleId:articleId
    }
  })
}
/**
 * 点差评和在点击取消差评
 * @param username
 * @param articleId
 * @returns {AxiosPromise}
 */
export function trampleAdd(username,articleId) {
  return Service({
    url: `/blogs-trample/trampleAdd`,
    params: {
      username:username,
      articleId:articleId
    }
  })
}
/**
 * 判断是否已差评
 * @param username
 * @param articleId
 * @returns {AxiosPromise}
 */
export function ifTrample(username,articleId) {
  return Service({
    url: `/blogs-trample/ifTrample`,
    params: {
      username:username,
      articleId:articleId
    }
  })
}
